<?php $user_info = $this->user_info; ?>
<div>
	<hr>
	<ul class="breadcrumb">
		<li>
			<a href="/user/index">Home</a> <span class="divider">/</span>
		</li>
		<li>
			<a href="/user/user">User</a> <span class="divider">/</span>
		</li>
        <li>
			<a href="/user/user/edit-info">Edit Info</a>
		</li>
	</ul>
	<hr>
</div>
<?php if(!empty($this->error)){ ?>
<div class="alert alert-error">
	<button type="button" class="close" data-dismiss="alert">×</button>
	<strong>Error!</strong> <?php echo $this->error; ?>.
</div>
<?php }?>
<?php if(!empty($this->success)){ ?>
<div class="alert alert-success">
	<button type="button" class="close" data-dismiss="alert">×</button>
	<strong>Success!</strong> <?php echo $this->success; ?>.
</div>
<?php }?>
<?php if(!empty($this->warning)){ ?>
<div class="alert alert-block ">
	<button type="button" class="close" data-dismiss="alert">×</button>
	<strong>Warning!</strong> <?php echo $this->warning; ?>
</div>
<?php }?>
<div class="row-fluid sortable">
	<div class="box span12">
		<div class="box-header" data-original-title>
			<h2><i class="icon-edit"></i><span class="break"></span>Cập nhật thông tin người dùng</h2>
		</div>
		<div class="box-content">
			<form class="form-horizontal" method="post">
			  <fieldset>
				<div class="control-group">
				  <label class="control-label" >Tên đầy đủ: </label>
				  <div class="controls">
					<input type="text" class="span6" name="FullName" value="<?php echo $user_info['FullName']; ?>" />
				  </div>
				</div>
                <div class="control-group">
    				<label class="control-label" for="category">Giới tính: </label>
    				<div class="controls">
    				  <select id="Gender" name="Gender" data-rel="chosen">
  				          <option value="1" <?php if($user_info['Gender'] == 1){?>selected=""<?php }?>>Nam</option>
                          <option value="0" <?php if($user_info['Gender'] == 0){?>selected=""<?php }?>>Nữ</option>
    				  </select>
    				</div>
    			</div>
				<div class="control-group">
				  <label class="control-label">Số điện thoại: </label>
				  <div class="controls">
					<input type="text" class="span6" name="PhoneNumber" value="<?php echo $user_info['PhoneNumber']; ?>" />
				  </div>
				</div>
                
                <div class="control-group">
				  <label class="control-label">Ngày sinh: </label>
				  <div class="controls">
                    <?php $BD_array = explode("-", $user_info['BirthDay']); ?> 
					<input type="text" class="span1" name="BD_Day" value="<?php echo !empty($BD_array[2]) ? $BD_array[2] : "1"; ?>" />
                    <span class="seperator">/</span>
                    <select id="BD_Month" name="BD_Month" data-rel="chosen" class="span2">
                        <?php for($i=1; $i<=12; $i++){ ?>
                            <option value="<?php echo $i?>" <?php if(!empty($BD_array[1]) && $BD_array[1] == $i){ ?>selected=""<?php } ?>>
                                Tháng <?php echo $i; ?>
                            </option>
                        <?php }?>
				    </select> 
                    <span class="seperator">/</span>
                    <input type="text" class="span1" name="BD_Year" value="<?php echo !empty($BD_array[0]) ? $BD_array[0] : "1990"; ?>" />
				  </div>
				</div>

				<div class="control-group">
				  <label class="control-label" for="fileInput">Avatar: </label>
				  <div class="controls">
					<input id="file_upload" type="file" />
                    <input id="Avatar" name="Avatar" type="hidden" value="<?php echo $user_info['Avatar']; ?>" />
                    <span>Hỗ trợ các file jpg, png, gif,..</span>
                    <div id="show_image">
                        <img id="image_demo" src="<?php echo $user_info['Avatar']; ?>" />
                    </div>
				  </div>
				</div>     
                <div class="control-group hidden-phone">
				  <label class="control-label" for="textarea2">Địa chỉ: </label>
				  <div class="controls">
                    <input type="text" class="span6" name="Address" value="<?php echo $user_info['Address']; ?>" />
				  </div>
				</div>
                <div class="control-group hidden-phone">
				  <label class="control-label" for="textarea2">Nick Facebook: </label>
				  <div class="controls">
                    <input type="text" class="span6" name="FaceAccount" value="<?php echo $user_info['FaceAccount']; ?>"
                     <?php if(!empty($user_info['face_account'])){ ?>readonly=""<?php } ?> />
				  </div>
				</div>     
				<div class="control-group hidden-phone">
				  <label class="control-label" for="textarea2">Mô tả ngắn về bản thân: </label>
				  <div class="controls">
					<textarea id="textarea2" rows="3" class="span6" name="Introduce">
                        <?php echo $user_info['Introduce']; ?>
                    </textarea>
				  </div>
				</div>
				<div class="form-actions">
				  <button type="submit" class="btn btn-primary">Cập nhật</button>
				  <button type="reset" class="btn">Làm lại</button>
				</div>
			  </fieldset>
			</form>   

		</div>
	</div><!--/span-->

</div><!--/row-->
<hr />
<script type="text/javascript">
    $(document).ready(function(){
        /* ---------- Uploadify ---------- */
    	$('#file_upload').uploadify({
    	   'formData'     : {
        		'folder'    : '/images/user/',
        		'fileext'	: '*.png;*.gif;*.jpg;*jpeg;*.bmp',
                'image_size'	: '1_0_0',
    		},
            'fileSizeLimit': 10000,
            'fileTypeExts' : '*.png; *.gif; *.jpg; *jpeg; *.bmp',
    		'swf'      : '/js/misc/uploadify.swf',
    		'uploader' : '/js/misc/uploadify.php',
            'cancelImg'     : '/js/misc/uploadify-cancel.png',
            'multi'         : false,
    		'onUploadSuccess'  : function(file, response, data) {
                var array_response = response.split("|");
                var response_code = array_response[0];
                if(response_code === "0"){
                    var size_banner = array_response[1];
                    var width = array_response[2];
                    var height = array_response[3];
                    var file_name = array_response[4];       	  
	               $("#image_demo").attr("src","/images/user/"+file_name);
                    $("#Avatar").val('/images/user/'+file_name);
                }else{
                    alert(response);
                }
    		},
    	    'auto'             : true,
    	    'onError'          : function(event, ID, fileObj, errorObj) {
    	        alert(errorObj.type+"::"+errorObj.info);
    	     },
    	}); 
    });
</script>
<style type="text/css">
#BD_Month_chzn{
    vertical-align: middle;
}
.seperator{
    margin: 0px 5px;
}
</style>